import Controller from "../GamePlayController";
const {ccclass, property} = cc._decorator;

@ccclass
export default class NewClass extends cc.Component {

    @property(Controller)
    controller : Controller = null;

    // onLoad () {}

    start () {

    }

    onBeginContact (contact, selfCollider, otherCollider) {


         var worldManifold = contact.getWorldManifold();
 
         var points = worldManifold.points;
          var normal = worldManifold.normal;
         //  cc.log("法向量方向",normal)
         //  cc.log("point",points)
         // cc.log("世界坐标的点",points)
             var localPoint
             localPoint = cc.v2();
             this.node.getComponent(cc.RigidBody).getLocalPoint(points[0], localPoint);
            //  cc.log("局部的点",localPoint)


              var localVector = cc.v2();
              this.node.getComponent(cc.RigidBody).getLocalVector(normal, localVector);

            //  cc.log("碰撞自身",selfCollider)
            //  cc.log("碰撞的另外一个刚体",otherCollider)
             this.controller.rigidBodyFinish(localPoint,localVector)

    }


    onEndContact (contact,selfCollider, otherCollider) {
    //    cc.log("onEndContact")
    }

    // // 每次将要处理碰撞体接触逻辑时被调用
    // onPreSolve(contact, selfCollider, otherCollider) {
    //     cc.log("onPreSolve")
    // }

    // // 每次处理完碰撞体接触逻辑时被调用
    // onPostSolve (contact, selfCollider, otherCollider) {
    //     cc.log("onPostSolv")
    // }

    // update (dt) {}
}
